<template>
    <div>
        基础信息<br>
        <p v-for="k,v in params" :key="v.id">
          {{v}}:{{k}}
        </p>
        审批信息
        <table>
            <tr v-for="j in task.audit_records" :key="j.id">
                <td>{{j.username}}</td>
                <td>{{j.is_agree}}</td>
                <td>{{j.add_time}}</td>
                <td>{{j.reason}}</td>
            </tr>
        </table>
        <br>
        审批信息
        <van-radio-group v-model="agree">
            <van-radio name="1">同意</van-radio>
            <van-radio name="0">不同意</van-radio>
        </van-radio-group>
        <van-field label="情况详情" v-model="reason"/>
        <van-button @click="submit">提交</van-button>
        

    </div>
</template>

<script>
import maxios from '../http/axios'
export default {
    data() {
        return {    
            taskid:this.$route.query.id,
            task:{},
            params:{},
            agree:1,
            reason:'',
            userid:localStorage.getItem('userid'),
            username:localStorage.getItem('username')
        }
    },
    methods: {
        getTask(){
            maxios('taskm','get',{'id':this.taskid}).then(res => {
                this.task = res.task
                this.params = JSON.parse(res.task.params)
            })
        },
        submit(){
             maxios('taskrecordM','post',{'taskid':this.taskid,'userid':this.userid,'username':this.username,
             'agree':this.agree,'reason':this.reason}).then(res => {
                console.log(res)
                this.getTask()
            })
        },
    },
    created() {
        this.getTask()
    }
}
</script>

<style scoped>

</style>
